package Student;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Random;

public class number2 {
	public static void main(String[] args) throws Exception {
		Random random = new Random();
		int num = random.nextInt(100)+1;
		String line = readLineFromFile("names.txt", num);
		System.out.println("恭喜抽到 "+line);
	}

	public static String readLineFromFile(String fileName, int lineNumber) throws Exception {
		BufferedReader reader = new BufferedReader(new FileReader(fileName));
		String line;
		int currentLineNumber = 1;
		while ((line = reader.readLine()) != null) {
			if (currentLineNumber == lineNumber) {
				return line;
			}
			currentLineNumber++;
		}
		return null;
	}
}
